//
//  ZLPullMenuContentCell.m
//  ZLPullMenu
//
//  Created by 赵振磊 on 2024/5/27.
//

#import "ZLPullMenuContentCell.h"
#import <Masonry/Masonry.h>

@interface ZLPullMenuContentCell()
/// 标题
@property (nonatomic, strong) UILabel *titleLabel;
@end

@implementation ZLPullMenuContentCell

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self.contentView addSubview:self.titleLabel];
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.mas_equalTo(UIEdgeInsetsZero);
        }];
    }
    return self;
}

- (void)setOption:(ZLPullMenuOption *)option {
    _option = option;
    self.titleLabel.text = option.optionTitle;
    if (option.selected) {
        self.titleLabel.textColor = option.config.textSelectedColor;
        self.titleLabel.font = option.config.selectedFont;
        self.titleLabel.backgroundColor = option.config.backgroundSelectedColor;
        self.titleLabel.layer.borderColor = option.config.borderSelectedColor.CGColor;
    } else {
        self.titleLabel.textColor = option.config.textColor;
        self.titleLabel.font = option.config.font;
        self.titleLabel.backgroundColor = option.config.backgroundColor;
        self.titleLabel.layer.borderColor = option.config.borderColor.CGColor;
    }
}

#pragma mark - init

- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.layer.borderWidth = 1;
        _titleLabel.layer.masksToBounds = YES;
        _titleLabel.layer.cornerRadius = 3;
        _titleLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _titleLabel;
}

@end
